package springboot.tools.state.handler;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;


/**
 * @Description: CIT任务处理
 * 里面添加一些公用方法
 * @Author: pengwenjuan
 * @Date: 2020-07-14
 */
public abstract class AbstractCitTaskHandler implements CitTaskHandler {

    protected Logger LOGGER = LoggerFactory.getLogger(getClass());

    @Autowired
    CitTaskDispatcher citTaskDispatcher;

    /**
     * 添加redis锁
     */
    protected boolean tryLock(String lockKey, int expireInSeconds) {
        return true;
    }

    /**
     * 查询请求数据（并校验状态是否一致）
     */
    protected String getAndCheckCitRequest(Long requestId, String status) {

        return null;
    }

    /**
     * 请求任务完成处理(增加备注)
     */
    protected void complete(Long requestId, String targetTaskStatus, String result) {

        //触发调度
        citTaskDispatcher.dispatcher(requestId);
    }

}
